import { ADD_TO_CART, ADD_COUNT } from "./mutation_typs"
const actions = {
    addToCart(context, payload) {
        let oldCartList = context.state.cartList.find(item => {
            return item.iid === payload.iid
        })
        if (oldCartList) {
            const index = context.state.cartList.indexOf(oldCartList)
            context.commit(ADD_COUNT, index)
        } else {
            payload.count = 1
            payload.checked = true
            context.commit(ADD_TO_CART, payload)
        }
    }
}

export default actions
